﻿using System;

namespace WikiDoc.Lines
{
    /// <summary>
    /// 表示一个列表行
    /// </summary>
    public class ListLine : WikiLine
    {
        /// <summary>
        /// 列表的缩进空白数（一个tab计算为一个空白）
        /// </summary>
        /// <value>The level.</value>
        public int Level { get; private set; }


        /// <summary>
        /// 列表内容的前的字符数
        /// </summary>
        /// <value>The level2.</value>
        public int Level2 { get; private set; }


        /// <summary>
        /// 列表内容，即去掉前导空白以及列表定义符号后的内容
        /// </summary>
        /// <value>The content.</value>
        public string Content { get; private set; }

        /// <summary>
        /// 初始化 <see cref="ListLine"/> 类的新实例.
        /// </summary>
        /// <param name="line">The line.</param>
        /// <param name="type">The type.</param>
        /// <param name="level">The level.</param>
        /// <param name="level2">The level2.</param>
        /// <param name="content">The content.</param>
        protected ListLine(string line, LineTypes type, int level, int level2, string content) : base(line, type)
        {
            if (line == null) throw new ArgumentNullException("line");

            if (content == null) throw new ArgumentNullException("content");

            if (type != LineTypes.BulletList && type != LineTypes.NumberList && type != LineTypes.AlphaList)
            {
                throw new ArgumentOutOfRangeException("type", type, "type 必须是 AlphaList、BulletList、NumberList");
            }

            if (level <= 0)
            {
                throw new ArgumentOutOfRangeException("level", level, "level 必须大于 0");
            }

            if (level >= level2)
            {
                throw new ArgumentException("level 必须小于 level2");
            }

            Line = line;
            Type = type;
            Level = level;
            Level2 = level2;
            Content = content;
        }

    }
}
